package com.qiche.controller.mgr;

import com.qiche.aspect.Result;
import com.qiche.model.Area;
import com.qiche.model.Bank;
import com.qiche.service.AreaService;
import com.qiche.service.BankService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 银行信息地域管理控制器
 * Created by Linzw on 2018/01/24.
 */
@Api(value = "/areas",description = "银行信息地域管理控制器")
@RestController
@RequestMapping("/areas")
public class AreaController {
	@Resource
	private AreaService areaService;
	@Resource
	private BankService bankService;


	@ApiOperation(value ="获取所有省份列表" )
	@GetMapping(value = "/getAllProvinces")
	public Result getAllProvinces() {

		List<Area> areaList = areaService.getAllProvinces();
		return Result.createBySuccess(areaList);
	}

	@ApiOperation(value ="根据省份代号获取所有城市列表" )
	@GetMapping(value = "/getAllCitys/{provinceCode}")
	public Result getAllCitys(@PathVariable("provinceCode") String provinceCode) {
		List<Area> cityList = areaService.getAllCitysByProviceCode(provinceCode);
		return Result.createBySuccess(cityList);

	}

	@ApiOperation(value ="根据城市代号获取所有区域列表" )
	@GetMapping(value = "/getAllDistricts/{cityCode}")
	public Result getAllDistricts(@PathVariable("cityCode") String cityCode) {
		List<Area> cityList = areaService.getAllDistrictsByCityCode(cityCode);
		return Result.createBySuccess(cityList);
	}

	@ApiOperation(value ="根据区域代号获取所有银行列表" )
	@GetMapping(value = "/getAllBanks/{districtCode}")
	public Result getAllBanks(@PathVariable("districtCode") String districtCode) {
		List<Bank> bankList=bankService.getAllBanksByDistrictCode(districtCode);
		return Result.createBySuccess(bankList);
	}
}
